<?php

namespace Trawind\Basics\Criteria;

use Prettus\Repository\Contracts\CriteriaInterface;
use Prettus\Repository\Contracts\RepositoryInterface;

/**
 * Class StatusInCriteria
 * @package Trawind\Basics\Criteria
 */
class StatusInCriteria implements CriteriaInterface
{


    protected $statusTypeIds;


    /**
     * StatusInCriteria constructor.
     * @param array|int $statusTypeIds
     */
    public function __construct($statusTypeIds)
    {
        $this->statusTypeIds = is_array($statusTypeIds) ? $statusTypeIds : [$statusTypeIds];
    }


    /**
     * Apply criteria in query repository
     *
     * @param  string  $model
     * @param  RepositoryInterface  $repository
     *
     * @return mixed
     */
    public function apply($model, RepositoryInterface $repository)
    {
        return $model->whereIn('status_type_id', $this->statusTypeIds);
    }
}
